<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
    <title>心理咨询预约系统</title>
    <script type="text/javascript" src="__USER__/js/jquery-1.8.0.js"></script>
    <!--    <script type="text/javascript" src="__USER__/jq/jquery.md5.js"></script>-->
    <script src="__USER__/js/layui/layui.js"></script>
    <script type="text/javascript" src="__ADMIN__/js/sliderVerify.js"></script>
    <link rel="stylesheet" href="__USER__/js/layui/css/layui.css">
    <link rel="stylesheet" href="__USER__/css/base.css">
    <link rel="stylesheet" href="__USER__/css/page/head.css">
    <link rel="stylesheet" href="__USER__/css/page/foot.css">
    <link rel="stylesheet" href="__USER__/css/page/index.css">
</head>
<body>
<div class="head-box">
    <div class="head-tit layui-row">
        <div class="headTit-inner layui-col-md-offset2 layui-col-md8">
            <div class="fl headTit-left">
                <div class="logo fl" style="margin-left: -40%">
                    <img src="__USER__/img/logo.png">
                </div>
                <div class="tit-txt fl" style="margin-left: -25%">
                    <div class="head-tit-bg"><a href="index.html">预约咨询服务平台</a></div>
                    <div class="head-tit-sm">预约诊疗服务平台</div>
                </div>
            </div>
            <div class="fr headTit-right layui-row" style="width: 500px">
                <ul>
                    <li class="layui-nav-item" style="margin-left:95%;margin-top:2%;width: 700px">
                        <a href="../student/info.html"><span style="font-size: 14px; color: #010101">欢迎,   </span><span
                                style="font-size: 20px; color: #0f6bed">   {$Request.session.studentname}   </span> </a>
                        <a style="text-decoration: none" href="javascript:void(0);" onclick="message()"><i
                                class="layui-icon layui-icon-notice"
                                title="消息"><span style="font-size: 14px; color: #2BC807">（{$count}）</span></i></a>

                        <a href="../student/logout"> <span style="font-size: 14px; color: #010101">    ,   退出</span></a>
                    </li>
                </ul>
                <div class="layui-row">

                </div>
            </div>
        </div>
    </div>

    <div class="head-tab layui-row">
        <div class="headTab-inner layui-col-md-offset2 layui-col-md8">
            <ul class="headTab-ul">
                <li>
                    <a href="order.html">预约咨询</a>
                </li>
                <li>
                    <a href="info.html">个人中心</a>
                </li>
                <li>
                    <a href="myorder.html">我的预约</a>
                </li>
                <li>
                    <a href="know.html">了解教师</a>
                </li>
                <li>
                    <a href="message.html">留言建议</a>
                </li>
            </ul>
        </div>
    </div>
</div>
<hr class="hr20">
<div class="layui-form" style="font-size: 15px">
    <div>

        <div style="font-family: 楷体;font-size: 30px;margin-left: 44%">新增个人预约</div>
        <hr class="hr15">
        <div class="layui-form-item" style="font-family: Consolas; margin-left: 16%">

            <div class="layui-inline">
                <label class="layui-form-label">学号：</label>
                <div class="layui-input-inline">
                    <input type="text" id="id" name="id" autocomplete="off"
                           disabled="disabled" class="layui-input" value="{$id}">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">姓名：</label>
                <div class="layui-input-inline">
                    <input type="text" id="name" name="name" disabled="disabled" autocomplete="off"
                           class="layui-input" value="{$name}">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">年龄：</label>
                <div class="layui-input-inline">
                    <input type="text" id="age" name="age" disabled="disabled" autocomplete="off"
                           class="layui-input" value="{$age}">
                </div>
            </div>
        </div>

        <div class="layui-form-item" style="font-family: Consolas; margin-left: 16%">
            <div class="layui-inline">
                <label class="layui-form-label">性别：</label>
                <div class="layui-input-inline">
                    <select id="sex" name="sex" disabled="disabled" autocomplete="off" class="layui-input">
                        {volist name="sexlist" id="vo" key="k"}
                        {eq name="vo" value="$sex"}
                        <option value="{$vo.sex}" selected>{$vo.sex}</option>
                        {else/}
                        <option value="{$vo.sex}">{$vo.sex}</option>
                        {/eq}
                        {/volist}
                    </select>
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">民族：</label>
                <div class="layui-input-inline">
                    <input type="text" id="nation" name="nation" disabled="disabled" lay-verify="required|nationname"
                           autocomplete="off"
                           class="layui-input" value="{$nation}">

                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">学院：</label>
                <div class="layui-input-inline">
                    <select id="depart" name="depart" disabled="disabled" autocomplete="off" class="layui-input">
                        {volist name="departlist" id="vo" key="k"}
                        {eq name="vo" value="$depart"}
                        <option value="{$vo.depart}" selected>{$vo.depart}</option>
                        {else/}
                        <option value="{$vo.depart}">{$vo.depart}</option>
                        {/eq}
                        {/volist}
                    </select>
                </div>
            </div>
        </div>


        <div class="layui-form-item" style="font-family: Consolas; margin-left: 16%">
            <div class="layui-inline">
                <label class="layui-form-label">手机：</label>
                <div class="layui-inline">
                    <input type="text" id="phone" name="phone" disabled="disabled" lay-verify="required"
                           autocomplete="off"
                           class="layui-input" style="width: 190px" value="{$phone}">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">地点：</label>
                <div class="layui-input-inline">
                    <select id="room" name="room" required lay-verify="required" autocomplete="off" class="layui-input">
                        {volist name="roomnumlist" id="vo" key="k"}
                        <option value=""></option>
                        <option value="{$vo.roomnum}">{$vo.roomnum}</option>
                        {/volist}
                    </select>
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">教师：</label>
                <div class="layui-input-inline">
                    <select id="ename" name="ename" lay-verify="required" autocomplete="off" class="layui-input">
                        {volist name="enamelist" id="vo" key="k"}
                        <option value=""></option>
                        <option value="{$vo.name}">{$vo.name}</option>
                        {/volist}
                    </select>
                </div>
            </div>
        </div>


        <div class="layui-form-item" style="font-family: Consolas; margin-left: 16%">
            <div class="layui-inline">
                <label class="layui-form-label">年级：</label>
                <div class="layui-inline" style="width: 190px">
                    <select id="slevel" name="slevel" style="width: 190px" lay-verify="required" autocomplete="off"
                            class="layui-input">
                        {volist name="slevellist" id="vo" key="k"}
                        <option value=""></option>
                        <option value="{$vo.slevel}">{$vo.slevel}</option>
                        {/volist}
                    </select>
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">日期：</label>
                <div class="layui-inline" style="width: 190px">
                    <input class="layui-input" placeholder="请选择今天之后的时间" required lay-verify="required" name="start"
                           id="start"></div>
            </div>


            <div class="layui-inline">
                <label class="layui-form-label">时间：</label>
                <div class="layui-inline" style="width: 190px">
                    <select id="time" name="time" style="width: 190px" lay-verify="required" autocomplete="off"
                            class="layui-input">
                        <option value=""></option>
                        <option value="8:00:00">8时</option>
                        <option value="9:00:00">9时</option>
                        <option value="10:00:00">10时</option>
                        <option value="11:00:00">11时</option>
                        <option value="14:00:00">14时</option>
                        <option value="15:00:00">15时</option>
                        <option value="16:00:00">16时</option>
                        <option value="17:00:00">17时</option>
                        <option value="18:00:00">18时</option>
                    </select>
                </div>
            </div>
        </div>

        <div class="layui-form-item" style="font-family: Consolas; margin-left: 16%">
            <div class="layui-inline">
                <label class="layui-form-label" style="margin-top: 25%">问题：</label>
                <div class="layui-input-inline">
                    <textarea rows="10" cols="30" id="content" name="content" required lay-verify="required"
                              placeholder="请描述你的问题和想咨询的内容。" autocomplete="off"
                              style="width: 850px; height: 200px;margin: 0;"></textarea>
                </div>
            </div>
        </div>

<!--        <div class="layui-form-item" style="font-family: Consolas; margin-left: 30%">-->
<!--            <div class="layui-form-item">-->
<!--                <label class="layui-form-label">滑动验证</label>-->
<!--                <div class="layui-input-block">-->
<!--                    <div id="slider"></div>-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->


        <div class="layui-form-item" style="font-family: Consolas;font-size: 18px; margin-left: 40%">
            <label class="layui-form-label"></label>
            <button class="layui-btn" lay-filter="update" id="update" lay-submit="update">提交预约</button>
        </div>
        <hr class="hr20">
    </div>
</div>

<div class="layui-row">
    <div class="layui-col-md-offset2 layui-col-md8">
        <div class="cardTit">
            <!-- <span class="cardTit-tit">友情链接</span> -->
        </div>
        <div class="body-card">
            <div id="linkurl" class="link-box">
            </div>
        </div>
    </div>
    <div class="layui-col-md12 foot-about">
        <div class="about-box">
            <div><a href="aboutUs.html">关于我们</a></div>
            <span>|</span>
            <div><a href="yinsi.html">隐私条款</a></div>
            <span>|</span>
            <div><a href="contactUs.html">联系我们</a></div>
            <div class="clear"></div>
        </div>
        <div>Copyright © 2019 - 2025 WEDOCTOR. All Rights Reserved. 苏孙举 版权所有</div>
    </div>
</div>
<script>

    layui.use(['form', 'layer', 'jquery', 'table'], function () {
        var table = layui.table;
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;
        var flag = 0;

        $(document).ready(function () {
            //消息检测
            if (flag == 0) {
                $.ajax({
                    type: "get",
                    url: "{:url('Student/checkmessage')}",
                    async: false,
                    success: function (data) {
                        console.log(data);
                        if (data != 0) {
                            layer.msg("您有（" + data + "）条新信息，请注意查看！");
                            flag = 1;
                        }
                    }
                });
            }
        });
    });

    //显示消息
    function message() {
        layer.open({
            type: 2,
            title: '',
            shadeClose: true,
            shade: 0.7,
            area: ['809px', '500px'],
            content: ['notify'],
            end: function () {
                $.ajax({
                    type: "get",
                    url: "{:url('Student/changenotify')}",
                    async: false,
                    success: function (data) {
                        console.log(data);
                        //考虑读完之后数字为0
                    }
                });
            }
        });
    }

    var studentid = "{:session('studentid')}";
    // console.log(studentid);
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#start', //指定元素
            min: getNowFormatDate(),
            type: 'date'
        });
    });

    function getNowFormatDate() {
        var date = new Date();
        var seperator1 = "-";
        var seperator2 = ":";
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
            + " " + date.getHours() + seperator2 + date.getMinutes()
            + seperator2 + date.getSeconds();
        return currentdate;
    }


    // // 滑块验证

    layui.use(['form', 'layer', 'jquery', 'table'], function () {
        var table = layui.table;
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;
        var code
        $("#update").click(function () {
            var id = $('#id').val();
            var name = $('#name').val();
            var age = $('#age').val();
            var sex = $('#sex').val();
            var nation = $('#nation').val();
            var depart = $('#depart').val();
            var phone = $('#phone').val();
            var address = $('#room').val();
            var ename = $('#ename').val();
            var slevel = $('#slevel').val();
            var date = $('#start').val();
            var time = $('#time').val();
            var content = $('#content').val();
            var otime = date + " " + time;
            // console.log(id);
            // console.log(name);
            // console.log(age);
            // console.log(sex);
            // console.log(nation);
            // console.log(depart);
            // console.log(phone);
            // console.log(address);
            // console.log(ename);
            // console.log(slevel);
            // console.log(date);
            // console.log(time);
            // console.log(otime);
            // console.log(content);
            $.ajax({
                type: "post",
                url: "../Student/insert",
                dataType: "json",
                data: {
                    "id": id, "sname": name, "age": age, "sex": sex, "nation": nation,
                    "depart": depart, "phone": phone, "address": address, "ename": ename, "slevel": slevel,
                    "time": otime, "content": content
                },
                async: false,//必须是同步提交的
                success: function (data) {
                    console.log(data);
                    if (data == 3) {
                        layer.msg("当前所选时间已过，请重新预约！", {icon: 2, time: 1000}, function () {
                            setTimeout('window.location.reload()', 100);
                        });
                    } else if (data == 4) {
                        layer.msg("所选时间与现在时间接近，请重新预约！", {icon: 2, time: 1000}, function () {
                            setTimeout('window.location.reload()', 100);
                        });
                    } else if (data == 1) {
                        layer.msg("预约成功！", {icon: 1, time: 1000}, function () {
                            setTimeout('window.location.href="myorder.html"', 100); //预约成功 跳转
                        });
                    } else if (data == 2) {
                        layer.msg("预约失败！", {icon: 2, time: 1000}, function () {
                            setTimeout('window.location.reload()', 100);
                        });
                    }
                },
            });

        });
    });
</script>
</body>
</html>